﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Geometry {
    public struct Point {
        public static Point ORIGIN = new Point(0, 0, 0);

        public float x, y, z;

        public Point(float x, float y, float z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }
        public Point(Point p) {
            this.x = p.x;
            this.y = p.y;
            this.z = p.z;
        }

        public static Point operator +(Point p, Point q) {
            return new Point(p.x + q.x, p.y + q.y, p.z + q.z);
        }
        public static Point operator +(Point p, Vector v) {
            return new Point(p.x + v.x, p.y + v.y, p.z + v.z);
        }
        public static Point operator -(Point p, Vector v) {
            return new Point(p.x - v.x, p.y - v.y, p.z - v.z);
        }
        public static Vector operator -(Point p, Point q) {
            return new Vector(p.x - q.x, p.y - q.y, p.z - q.z);
        }
        public static Point operator *(Point p, float t) {
            return new Point(t * p.x, t * p.y, t * p.z);
        }
        public static Point operator *(float t, Point p) {
            return p * t;
        }
        public static Point operator /(Point p, float t) {
            float r = 1.0f / t;
            return p * r;
        }
        public static Point operator -(Point p) {
            return new Point(-p.x, -p.y, -p.z);
        }

        public static float distance(Point p, Point q) {
            return (p - q).length();
        }
        public static float square(Point p, Point q) {
            return (p - q).square();
        }

        public float distance(Point p) { return (this - p).length(); }
        public float square(Point p) { return (this - p).square(); }
    }
}
